{% extends "base/_base.html" %}


{% block  title %}{{ view.model_meta.verbose_name }}{% endblock %}

{% block page-content %}

    {% add "ops:" view.model_meta.model_name as viewname %}
    {% add viewname "_add" as viewname_add %}
    {% add viewname "_update" as viewname_update %}
    {#% add viewname "_delete" as viewname_delete %#}

    <div class="row wrapper border-bottom white-bg page-heading">
        <div class="col-lg-10">
            <h2>用户管理</h2>
            <ol class="breadcrumb">
                <li>
                    <a href="/">主页</a>
                </li>
                <li class="active">
                    <strong>{{ view.model_meta.verbose_name }}</strong>
                </li>
            </ol>
        </div>
        <div class="col-lg-2">

        </div>
    </div>
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>数据列表</h5>

                    </div>
                    <div class="ibox-content">

                          <div class="table-responsive">{% url viewname_add as obj_add %}

                            <a href="{{ obj_add }}" class="btn btn-primary">添加</a>

                            <a class="btn btn-danger">批量删除</a>


                            <form id="list_object_form" class="form-horizontal  ">


                            <table class="table table-striped table-bordered table-hover dataTables-example">
                                <thead>
                                <tr>
                                    <th width="20"><input type="checkbox" id="CheckedAll"></th>
                                    <th>组名/角色</th>
                                    <th>包含用户</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                {% for object in object_list %}

                                    <tr id="{{ object.id }}">
                                        <td><input type="checkbox" value="{{ object.id }}"  name="id"></td>
                                        <td class="center">{% url viewname_update object.id as obj_update %}
                                            <a href="{{ obj_update }}">{{ object.name }}</a>
                                        </td>

                                        <td>

                                            {% for i in object.user_set.all %}
                                            <i class="fa fa-user"></i> {{ i }}<br/>
                                            {% empty %}
                                            为空
                                            {% endfor %}
                                        </td>

                                        <td>
                                            <!-- <a class="btn btn-primary  btn-xs " href="/admin/cmdb/hostuser/{{ object.id }}/change/" target="_blank">详细信息</a> -->
                                            <a class="btn btn-danger btn-xs">删除</a>

                                        </td>
                                    </tr>
                                {% endfor %}

                                </tbody>

                            </table>

                            </form>


                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>

{% endblock %}



{% block footer-js %}

    <script>
        $(function () {

            $('.btn-danger').click(function () {
                // 删除model表obj数据
                DeleteObj(this)
            });

        });

    </script>


    {% block list_js %}
        <!-- 列表页js -->
    {% endblock %}

{% endblock %}

